import React, { PureComponent } from 'react';
import WPT from 'wpt';
import cns from 'classnames';

import S from './index.m.less';

export default class FixedBottom extends PureComponent {
    static defaultProps = {
        style: {},
        className: '',
        holder: null,
        holderHeight: 0,
        scrollHide: false, // 废弃属性无用
    };

    // 是不是在微拍堂体系内呀~
    get isInWPT() {
        const { os } = WPT;

        return (os.wechat || os.wpt || os.xcx);
    }

    addRef = d => {
        this.dom = d;
    };

    addWarpRef = d => {
        this.warpDom = d;
    };

    render() {
        const {
            className, style, holder, holderHeight
        } = this.props;

        return (
            <div ref={this.addWarpRef}>
                {holder || <div name="fixeHolder" className={S.holder} style={{ height: holderHeight }} />}
                <div className={cns(S.fixed, !this.isInWPT && S.fix, className)} style={style} ref={this.addRef}>
                    {this.props.children}
                </div>
            </div>
        );
    }
}
